package top100.dynamic;

import top100.twopointer.Solution287;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author ZhangCuirong
 * @Date 2025/8/26 11:28
 * @description:
 */
public class Solution118 {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> res = new ArrayList<>();
        for (int i = 0; i < numRows; i++) {
            List<Integer> row = new ArrayList<>();
            for (int j = 0; j <= i; j++) {
                if (j == 0 || j == i) {
                    row.add(1);
                } else {
                    row.add(res.get(i - 1).get(j - 1) + res.get(i - 1).get(j));
                }

            }
            res.add(row);

        }
        return res;
    }

    public static void main(String[] args) {
        Solution118 solution = new Solution118();
        List<List<Integer>> res = solution.generate(5);
        System.out.println(res);
    }
}
